<script>
  const { ipcRenderer } = require('electron')

  function doWork(input) {
    return input * 2
  }

  ipcRenderer.on('new-client', (event) => {
    const [port] = event.ports
    port.onmessage = (event) => {
      const result = doWork(event.data)
      console.info('post message: ', result)
      port.postMessage(result)
    }
  })
</script>